<?php 
$category_meta = array(
    array(
        "name" => "categorytitle",
        "std" => "",
        "title" => __('自定义SEO标题', 'haoui') . '：',
        'desc' => __('在HTML的title标签中，自定义分类标题将覆盖默认分类标题', 'haoui'),
    ),
    array(
        "name" => "categorykws",
        "std" => "",
        "title" => __('自定义分类SEO关键词', 'haoui') . '：',
        'desc' => __('在HTML的keywords标签中，自定义分类关键词将覆盖默认分类关键词', 'haoui'),
    ),
    array(
        "name" => "categorydes",
        "std" => "",
        "title" => __('自定义分类SEO描述', 'haoui') . '：',
        'desc' => __('在HTML的description标签中，自定义分类描述将覆盖默认分类描述', 'haoui'),
    ),
);

function ifan_add_category_field()
{
    global $category_meta;
    foreach ($category_meta as $meta_box) {
        echo '<div class="form-field">
    <label for="' . $meta_box['name'] . '">' . $meta_box['title'] . '</label>
    <input name="' . $meta_box['name'] . '" id="' . $meta_box['name'] . '" type="text" value="" size="40">
    <p>' . $meta_box['desc'] . '</p>
    </div>';
    }
}

function ifan_edit_category_field($tag)
{
    global $category_meta;
    foreach ($category_meta as $meta_box) {
        echo '<tr class="form-field">
    <th scope="row"><label for="' . $meta_box['name'] . '">' . $meta_box['title'] . '</label></th>
    <td>
    <input name="' . $meta_box['name'] . '" id="' . $meta_box['name'] . '" type="text" value="';
        echo get_option('' . $meta_box['name'] . '-' . $tag->term_id) . '" size="40"/><br>
    <span class="' . $meta_box['name'] . '">' . $meta_box['desc'] . '</span>
    </td>
    </tr>';
    }
}

function ifan_category_save($term_id)
{
    global $category_meta;
    foreach ($category_meta as $meta_box) {
        $data = $_POST[$meta_box['name']];
        if (isset($data)) {
            if (!current_user_can('manage_categories')) {
                return $term_id;
            }
            $key = $meta_box['name'] . '-' . $term_id;
            update_option($key, $data);
        }
    }
}
 ?>